#ifndef _UTILS_HXX__
#define _UTILS_HXX__

#include "macro.hxx"

namespace runtime {

static inline int FindNumThreads(int dim, int max_nthrs) {
  int ret = max_nthrs;
  while (ret > dim) {
    ret = ret >> 1;
  }
  return ret;
}

template <uint nstm=8>
struct helper_t{
  cudaStream_t stream[nstm];
  void build(){ for(int i=0;i<nstm;++i) H_ERR(cudaStreamCreate(&stream[i])); }
};

}

#endif 
